/*
 * 项目名称:项目名称
 * 类名称:MldCustomReservationController.java
 * 包名称:com.tongyi.modules.mld.controller
 * @author tianjin
 * @date 2024-06-25 22:58:30
 * Copyright (c) 2019-2021 惠州市酷天科技有限公司
 */
package com.tongyi.modules.mld.controller;

import com.tongyi.annotation.IgnoreAuth;
import com.tongyi.common.annotation.SysLog;
import com.tongyi.common.utils.RestResponse;
import com.tongyi.core.PageInfo;
import com.tongyi.modules.mld.controller.vo.MldCustomReservationVo;
import com.tongyi.modules.mld.entity.MldCustomReservationEntity;
import com.tongyi.modules.mld.service.IMldCustomReservationService;
import com.tongyi.modules.mld.service.MldCustomReservationService;
import com.tongyi.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Controller
 *
 * @author tianjin
 * @date 2024-06-25 22:58:30
 */
@RestController
@RequestMapping("mld/customreservation")
public class MldCustomReservationController extends AbstractController {
    @Autowired
    private MldCustomReservationService mldCustomReservationService;

    @Autowired
    private IMldCustomReservationService iMldCustomReservationService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping(value = "/listAll")
    @RequiresPermissions("mld:customreservation:list")
    public RestResponse listAll(@RequestParam Map<String, Object> params) {
        List<MldCustomReservationVo> list = iMldCustomReservationService.listAll(params);
        return RestResponse.success("list", list);
    }

    /**
     * 分页查询
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping("/list")
    @RequiresPermissions("mld:customreservation:list")
    public RestResponse list(@RequestParam(value = "page", defaultValue = "1") int current, @RequestParam(value = "limit", defaultValue = "10") int size, @RequestParam Map<String, Object> params) {
        PageInfo page = iMldCustomReservationService.listPage(current, size, params);
        return RestResponse.success("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return RestResponse
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("mld:customreservation:info")
    public RestResponse info(@PathVariable("id") Long id) {
        MldCustomReservationEntity mldCustomReservation = mldCustomReservationService.getById(id);
        return RestResponse.success("info", mldCustomReservation);
    }

    /**
     * 新增
     *
     * @param entity
     * @return RestResponse
     */
    @SysLog("新增")
    @PostMapping("/save")
    @RequiresPermissions("mld:customreservation:save")
    public RestResponse save(@RequestBody MldCustomReservationEntity entity) {
        iMldCustomReservationService.add(entity);
        return RestResponse.success();
    }

    /**
     * 修改
     *
     * @param entity
     * @return RestResponse
     */
    @SysLog("修改")
    @PostMapping("/update")
    @RequiresPermissions("mld:customreservation:update")
    public RestResponse update(@RequestBody MldCustomReservationEntity entity) {
        iMldCustomReservationService.update(entity);
        return RestResponse.success();
    }

    /**
     * 根据主键删除
     *
     * @param ids
     * @return RestResponse
     */
    @SysLog("删除")
    @PostMapping("/delete")
    @RequiresPermissions("mld:customreservation:delete")
    public RestResponse delete(@RequestBody Long[] ids) {
        mldCustomReservationService.deleteBatch(ids);
        return RestResponse.success();
    }


}
